package com.itany.corejava.day09;

public class TestInnerClass2 {

    public static void main(String[] args) {
        OuterB outerB=new OuterB();
        MyInterface i=outerB.f1();
        //---------------------------------------------
        i.innerF();
    }

}

class OuterB{
    private int i=1;

    public MyInterface f1(){
        int j=2;
        // final int j=1;
        //局部内部类
        class InnerC implements MyInterface{
            public void innerF(){
                System.out.println(i);
                System.out.println(j);
                // j=3;
            }
        }

        InnerC innerC=new InnerC();

        innerC.innerF();

        return innerC;
    }

    public MyInterface f2(){
        int j=2;
        //匿名内部类
        return new MyInterface(){

            @Override
            public void innerF() {
                System.out.println(i);
                System.out.println(j);
                // j=3;
            }
        };
    }

}


interface MyInterface{
    public void innerF();
}